SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 62503: An error is returned when you try to add datetime values to an SQL Server table using a libref with SAS/ACCESS® Interface to OLE DB

DetailsHotfixAboutRate It
When you try to add datetime values to a Microsoft SQL Server table using SAS/ACCESS Interface to OLE DB, the action fails with an error similar to the following:
ERROR: Value 1 on the SELECT clause does not match the data type of the corresponding column listed after the INSERT table name.
This problem occurs under the following conditions:
  • You use two OLE DB librefs connected to the same SQL Server database.
  • You create a table in SQL Server with a datetime value.
  • You add more datetime values into the same SQL Server table using a different libref.

Example

For example, you might encounter this problem if you submit code similar to the following:

libname x oledb provider=sqlncli11 datasource=marlin user=sasdemo pwd=Pass123;
libname y oledb provider=SQLOLEDB  datasource=marlin user=sasdemo pwd=Pass123;
* libref y refers to different provider from libref x ;
data work.foo;
  format dttmcol datetime.;
  dttmcol='01JAN2018 11:23'DT;
run;
proc sql;
  drop table x.demotest;
  create table x.demotest as select * from work.foo;
  * CREATE TABLE "demotest" ("dttmcol" datetime2(0));
  
  insert into x.demotest values('21JUN2018 12:34'DT);
  * OK;
  insert into y.demotest values('22JUN2018 12:34'DT);
  /* ERROR: Value 1 of VALUES clause 1 does not match the data type of the corresponding column in the
       object-item list (in the SELECT clause). ;  */
quit;

Background and Cause

The SQL Server database has several providers, including the following:
  • SQL Server Native Client 11.0 (SQLNCLI11)
  • SQL Server Native Client 10.0 (SQLNCLI10)
  • Microsoft OLE DB Provider for SQL Server (SQLOLEDB)
SQLNCLI11 and SQLNCLI10 support the new DATETIME2 data type for SQL Server 2008 and later. But, SQLOLEDB does not recognize the DATETIME2 data type.
 
In an effort to save some time during connections, SAS attempts to save and reuse data-type information if multiple librefs are connected to the same data source. When two librefs are connected to the same data source, data-source information is shared across the librefs. 
 
The issue occurs because a data type that is supported by one provider might not be supported by other providers for the same database server. Because the shared data-source information could be used by a provider that does not support it, SAS returns the error message.
 
As a workaround, use the SQL Server Native Client 11 provider instead of the Microsoft OLE DB Provider for SQL Server for all librefs.
 
Click the Hot Fix tab in this note to access the hot fix for this issue.


Operating System and Release Information

Product FamilyProductSystemProduct ReleaseSAS Release
ReportedFixed*ReportedFixed*
SAS SystemSAS/ACCESS Interface to OLE DBMicrosoft® Windows® for x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8 Enterprise 32-bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8 Enterprise x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8 Pro 32-bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8 Pro x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8.1 Enterprise 32-bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8.1 Enterprise x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8.1 Pro 32-bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 8.1 Pro x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows 109.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 20089.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 2008 R29.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 2008 for x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 2012 Datacenter9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 2012 R2 Datacenter9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 2012 R2 Std9.4_M49.4_M59.4 TS1M49.4 TS1M5
Microsoft Windows Server 2012 Std9.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Enterprise 32 bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Enterprise x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Home Premium 32 bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Home Premium x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Professional 32 bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Professional x649.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Ultimate 32 bit9.4_M49.4_M59.4 TS1M49.4 TS1M5
Windows 7 Ultimate x649.4_M49.4_M59.4 TS1M49.4 TS1M5
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.